package com.google.way1;


import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;

public class MyLinearLayoutForListAdapter extends LinearLayout {
	
	public AdapterForLinearLayout adapter;
	public OnClickListener mOnClickListener = null;

	public MyLinearLayoutForListAdapter(Context context) {
		super(context);
	}
	
	public MyLinearLayoutForListAdapter(Context context, AttributeSet attrs) {
	        super(context, attrs);
	}
	
	public void bindLinearLayout(){
		int count = adapter.getCount();
		for(int i=0;i<count;i++){
			View v = adapter.getDropDownView(i, null, null);
			
			v.setOnClickListener(this.mOnClickListener);
//			if( i == count-1){
//				LinearLayout ly = (LinearLayout)v;
//				ly.removeViewAt(2);
//			}
			this.addView(v, i);
		}
		 Log.v("countTAG", "" + count);
	}
	
	public AdapterForLinearLayout getAdapter(){
		return adapter;
	}
	
	public void setAdapter(AdapterForLinearLayout adapter){
		this.adapter = adapter;
		bindLinearLayout();
	}
	
	public void setOnClickListener(OnClickListener mOnClickListener){
		this.mOnClickListener = mOnClickListener;
	}
	
	public OnClickListener getOnClickListener(){
		return mOnClickListener;
	}

}
